package com.vita.testCore1.execute;

import com.vita.testCore1.Data.ValueStore;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * 执行器基类，用来
 *
 * Execute 代理 NnExecute 的功能
 */
public class Execute extends ValueStore implements InvocationHandler {
    private Object targetObject;
    public Object newProxyInstance(Object targetObject){
        this.targetObject=targetObject;
        return Proxy.newProxyInstance(targetObject.getClass().getClassLoader(),
                targetObject.getClass().getInterfaces(),this);
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        Object ret=null;
        try{
            ret=method.invoke(targetObject, args);
        }catch(Exception e){
            throw e;
        }
        return ret;
    }

}
